#!/bin/sh
################################################################################
# browsers
################################################################################
. /etc/rc.d/functions

start() {
    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/browsers] Starting..."

    if [ "x${MM_NETFLIX_ENABLED}" = "xyes" ] ; then

        mm_confrw_get google-chrome-config.tar.bz2 /home/minimyth/google-chrome-config.tar.bz2
        if [ ! -e /home/minimyth/google-chrome-config.tar.bz2 ] ; then
            /usr/bin/logger -t minimyth -p "local0.err" "[init.d/browsers] can't download chrome state archive (google-chrome-config.tar.bz2)..."
            return 1
        else
            /bin/rm -rf /home/minimyth/.config*
            bunzip2 -dc /home/minimyth/google-chrome-config.tar.bz2 | tar -xf - -C /home/minimyth
            /bin/rm -f /home/minimyth/google-chrome-config.tar.bz2
            /usr/bin/logger -t minimyth -p "local0.info" "[init.d/browsers] Google-chrome config sucessfuly restored..."
        fi

        mm_confrw_get mozilla-firefox-config.tar.bz2 /home/minimyth/mozilla-firefox-config.tar.bz2
        if [ ! -e /home/minimyth/mozilla-firefox-config.tar.bz2 ] ; then
            /usr/bin/logger -t minimyth -p "local0.err" "[init.d/browsers] can't download chrome state archive (mozilla-firefox-config.tar.bz2)..."
            return 1
        else
            /bin/rm -rf /home/minimyth/.mozilla*
            bunzip2 -dc /home/minimyth/mozilla-firefox-config.tar.bz2 | tar -xf - -C /home/minimyth
            /bin/rm -f /home/minimyth/mozilla-firefox-config.tar.bz2
            /usr/bin/logger -t minimyth -p "local0.info" "[init.d/browsers] Mozilla-firefox config sucessfuly restored..."
        fi

    fi

    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/browsers] Started with return code=0..."

    return 0
}

stop() {
    return 0
}

case $1 in
    start) start ;;
    stop)  stop  ;;
esac

exit 0
